package com.prj.ufdm.cloud.ms.core.enums;

/**
 * 日志类型
 * @author: zhujq
 * @date: 2019/9/20 11:46
 */
public enum LogTypeEnum {

    /**
     * 登录日志
     */
    LOGIN("1", "LOGIN"),
    /**
     * 操作日志
     */
    BUSINESS("2", "BUSINESS"),
    /**
     * 错误日志
     */
    ERROR("3", "ERROR"),
    /**
     * 变更日志
     */
    CHANGE("4", "CHANGE");

    private String code;

    private String label;

    public static String getLabelByCode(int code){
        String label = "";
        for (LogTypeEnum logTypeEnum : LogTypeEnum.values()) {
            if(logTypeEnum.code.equals(code)){
                label = logTypeEnum.label;
            }
        }
        return label;
    }

    public static String getCodeBylabel(String label){
        String code = null;
        for (LogTypeEnum logTypeEnum : LogTypeEnum.values()) {
            if(logTypeEnum.label.equalsIgnoreCase(label)){
                code = logTypeEnum.code;
            }
        }
        return code;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    LogTypeEnum(String code, String label) {
        this.code = code;
        this.label = label;
    }
}
